﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using KPIS.GERP.GHRMS.BLL;
using KPIS.GERP.GHRMS.IBLL;
using Telerik.Web.UI;

namespace KPIS.GERP.GHRMS.APP.App_UI.Forms
{
    public partial class TR_TrainingSubject : System.Web.UI.Page
    {
        InitialData_BLL iniData = new InitialData_BLL();
        
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadDataGrid();
            }
            
        }
        
        private void LoadDataGrid()
        {
            try
            {
                DataSet ListSalaryCommand = iniData.ListTrainingSubject("");
                RadGrid2.DataSource = ListSalaryCommand.Tables[0];
                RadGrid2.DataBind();
            }
            catch (Exception ex)
            {

            }
        }

        protected void RadGrid2_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
        {
            if (e.CommandName == "Sort" || e.CommandName == "Filter")
            {
                LoadDataGrid();
            }
            if (e.CommandName == "ExpandCollapse")
            {
                return;

            }
            if (e.CommandName == "Delete")
            {
                if (e.Item is GridDataItem)
                {
                    GridDataItem item = (GridDataItem)e.Item;
                    Int32 StatusSeq = Convert.ToInt32(item["training_subject_seq"].Text);
                    iniData.DeleteTrainingSubject(StatusSeq, "1");
                }
            }
            LoadDataGrid();
            //if (e.CommandName == "Delete")
            //{
            //    int seq = Convert.ToInt32((e.Item as GridDataItem).OwnerTableView.DataKeyValues[e.Item.ItemIndex]["Sequence"]);
            //    iniData.DeleteTrainingSubject(seq, "1");
            //}
            //if (e.CommandName == "ExpandCollapse")
            //    return;
            //LoadDataGrid();
        }

        //protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e)
        //{
            
        //}
    }
}
